#ifndef _RECORDMANAGER_H_
#define _RECORDMANAGER_H_
#include "BufferManager.h"
#include "UserCommand.h"
#include <stdio.h>
#include <vector>
#include <string>
#include <memory>

struct DataLine{
	int line;
	std::vector<std::string> columns;
};

class Record
{
public:
	Record(std::shared_ptr<BufferManager> buffer);
	~Record();
	void createTable(std::string tableName);

	std::vector<std::string> select(std::string tableName, Attribute attr, std::vector<Attribute> attribute);
	std::vector<std::vector<std::string>> select(std::string tableName, CUserCommand userCommand, std::vector<Attribute> Attribute);
	std::vector<std::vector<std::string>> select(std::string tableName, CUserCommand userCommand,std::vector<Condition> condition, std::vector<Attribute> attribute);
	std::vector<std::vector<std::string>> select(std::string tableName, CUserCommand userCommand,std::vector<Attribute> attribute, std::vector<int> resultRowNum);
	std::vector<int> select(std::string tableName, std::vector<Condition> condition, std::vector<Attribute> attribute);

	void dropTable(std::string tableName, std::vector<Attribute> attribute);
	std::vector<DataLine> deleteRecord(std::string tableName, std::vector<int> resultRowNum, std::vector<Attribute> attribute);
	int insert(std::string tableName, std::vector<std::string> values, std::vector<Attribute> attribute);

	int getAttrPosSize(int attrPos, std::vector<Attribute> attribute);
	int getRowDataSize(std::vector<Attribute> attribute);

	int getBlockNum(std::vector<Attribute> attribute, int rowNum);
	int getBlockRecordNum(std::vector<Attribute> attribute);

private:
	std::shared_ptr<BufferManager> buffer;
	//std::shared_ptr<IndexManager> index;
	//int totalRecordCount;
	//std::vector<tableRecord> tablerecord;
};

#endif
